﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using OCR.Config;

namespace OCR.SystemThread
{
    class SendIO_NGThread_All
    {
        public static bool SendIO_NG_Flowrec = false;
        public static Thread SendIO_NGFlow_Thread = null;
        public static int iSendIO_NG_Step = 0;

        public static bool SendIO_NG_Stop = false;

        public static bool isSendIO = false;
        public static void SendIO_NG_Thread()
        {

            iSendIO_NG_Step = 0;
            SendIO_NG_Flowrec = true;
            SendIO_NGFlow_Thread = new Thread(SendIO_NGFlowThread);
            SendIO_NGFlow_Thread.IsBackground = true;
            SendIO_NGFlow_Thread.Start();

        }

        private static void SendIO_NGFlowThread(object obj)
        {
            while (SendIO_NG_Flowrec)
            {
                switch (iSendIO_NG_Step)
                {
                    case 5:
                        Thread.Sleep(int.Parse(LocalInfo.CloseSignalDelayTime));//30~500
                        IOThread_Run.DO_Trigger_olng(1, 0);
                        IOThread_Run.DO_Trigger_olng(2, 0);
                        IOThread_Run.DO_Trigger_olng(3, 0);
                        IOThread_Run.DO_Trigger_olng(4, 0);
                        Console.WriteLine("CloseIO_NGThread---------All");
                        iSendIO_NG_Step = 0;

                        break;
                }
                Thread.Sleep(1);
            }
        }
    }
}
